home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 May (DVD) / Macworld Resource DVD May 2003.toast / Data / Software / Bonus / Database / mysql-max-3.23.55.sit / mysql-max-3.23.55-apple-darwi.1 / mysql-test / t / select_safe.test < prev    next >
Encoding:
Text File  |  2003-01-21  |  983 b   |  33 lines  |  [TEXT/ttxt]

  1. #
  2. # test of safe selects
  3. #
  4.  
  5. drop table if exists t1;
  6. SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=4, SQL_MAX_JOIN_SIZE=9;
  7. create table t1 (a int primary key, b char(20));
  8. insert into t1 values(1,"test");
  9. SELECT SQL_BUFFER_RESULT * from t1;
  10. update t1 set b="a" where a=1;
  11. delete from t1 where a=1;
  12. insert into t1 values(1,"test"),(2,"test2");
  13. SELECT SQL_BUFFER_RESULT * from t1;
  14. update t1 set b="a" where a=1;
  15. select 1 from t1,t1 as t2,t1 as t3,t1 as t4;
  16.  
  17. # The following should give errors:
  18. !$1175 update t1 set b="a";
  19. !$1175 update t1 set b="a" where b="test";
  20. !$1175 delete from t1;
  21. !$1175 delete from t1 where b="test";
  22. !$1175 delete from t1 where a+0=1;
  23. !$1104 select 1 from t1,t1 as t2,t1 as t3,t1 as t4,t1 as t5;
  24.  
  25. # The following should be ok:
  26. update t1 set b="a" limit 1;
  27. update t1 set b="a" where b="b" limit 2; 
  28. delete from t1 where b="test" limit 1;
  29. delete from t1 where a+0=1 limit 2;
  30. drop table t1;
  31.  
  32. SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, SQL_MAX_JOIN_SIZE=DEFAULT;
  33.